package com.money.shell.model
{
	import com.money.common.remoting.IInvokeResponder;
	import com.money.shell.model.services.MenuService;
	import com.money.shell.ShellFacade;
	import mx.collections.ArrayCollection;
	import mx.collections.XMLListCollection;
	import mx.controls.Alert;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.RemoteObject;
	
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.interfaces.IProxy;
	import org.puremvc.as3.multicore.patterns.proxy.Proxy;

	public class MenuProxy extends Proxy implements IProxy
	{
		public static const NAME:String="MenuProxy";
		
		private var menuService:MenuService;
		public function MenuProxy()
		{
			super(NAME, data);
		}
		override public function onRegister():void
		{
			iniMenu();
		}
		override public function onRemove():void
		{
		}
		public function iniMenu():void
		{
			menuService=new MenuService();
			var iInvokeResponder:IInvokeResponder=menuService.iniMenu();
			iInvokeResponder.addResultListener(resultHandler);
			iInvokeResponder.addFaultListener(faultHandler);
		}
		private function resultHandler(event:ResultEvent):void
		{
			var menuList:ArrayCollection=event.result as ArrayCollection;
			
			if(menuList!=null){
				sendNotification(ShellFacade.MENUINI,menuList);
			}
			else{
				Alert.show("menu为空");
			}
			
		}
		private function faultHandler(event:FaultEvent):void
		{
			Alert.show(event.fault.toString());
		}
	}
}